<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        const p = new Promise(function (resolve, reject) {
            // 
            setTimeout(() => {
                const n = parseInt(Math.random() * 100);
                if (n % 2 === 0) {
                    // success('我中奖号码:' + n) ;
                    resolve(n)
                } else {
                    // fail('没有中奖，号码是:' + n) ;
                    reject(n)
                }
            }, 2000)
        })



        // 语法 then(cb1 , cb2) 
        p.then(
            (data) => {
                console.log('中奖啦:' + data);
            } ,
            (err) => {
                console.log('很遗憾:' , err);
            }
        )

    </script>

</body>

</html>